local skel = fk.CreateSkill {
  name = "emo__huaxu",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__huaxu"] = "华胥",
  [":emo__huaxu"] = "锁定技，一名角色首次进入濒死状态时，你回复1点体力，然后你选择一种非“转运”花色，将选择的花色记为“转运”花色。",

  ["#emo__huaxu-choice"] = "华胥：请选择一种花色，将此花色也标记为“转运”花色",

  ["$emo__huaxu1"] = "兔子先生，能抱抱雏桃吗？嗯，果然好温暖，让人想要睡觉呢～",
  ["$emo__huaxu2"] = "兔子先生希望雏桃亲口说晚安吗？嗯，明白了……“啾——兔子先生晚安～～”",
}

skel:addEffect(fk.EnterDying, {
  anim_type = "defensive",
  can_trigger = function (self, event, target, player, data)
    if not player:hasSkill(skel.name) then return false end
    local current = player.room.logic:getCurrentEvent():findParent(GameEvent.Dying, true)
    if current then
      local first = player.room.logic:getEventsOfScope(GameEvent.Dying, 1, function (e)
        return e.data.who == data.who
      end, Player.HistoryGame)[1]
      return first and first.id == current.id
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:recover { num = 1, skillName = skel.name, who = player, recoverBy = player }
    if player.dead then return end
    local all_choices = {"log_spade", "log_heart", "log_club", "log_diamond"}
    local choices = table.filter(all_choices, function (suit)
      return not table.contains(player:getTableMark("@emo__zhuanyun"), suit)
    end)
    if #choices == 0 then return end
    local choice = room:askToChoice(player, {
      choices = choices, skill_name = skel.name, prompt = "#emo__huaxu-choice", all_choices = all_choices,
    })
    room:addTableMark(player, "@emo__zhuanyun", choice)
    player:filterHandcards()
  end,
})

return skel
